package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.TenantCompanyEntity;
import com.uchiha.nova.core.model.vo.TenantCompanyVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.ITenantCompanyService;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 公司表 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class TenantCompanyWrapper extends BaseEntityWrapper<TenantCompanyEntity, TenantCompanyVO>  {
  
  ITenantCompanyService tenantCompanyService = SpringUtil.getBean(ITenantCompanyService.class);
  
	public static TenantCompanyWrapper build() {
		return new TenantCompanyWrapper();
 	}

	@Override
	public TenantCompanyVO entityVO(TenantCompanyEntity tenantCompanyEntity) {
		TenantCompanyVO tenantCompanyVO = new TenantCompanyVO();
		BeanUtil.copyProperties(tenantCompanyEntity, tenantCompanyVO);

		return tenantCompanyVO;
	}
	public List<TenantCompanyVO> listVO(List<TenantCompanyEntity> list) {
		List<TenantCompanyVO> collect = list.stream().map(item -> {
            TenantCompanyVO tenantCompanyVO = new TenantCompanyVO();
		    BeanUtil.copyProperties(item, tenantCompanyVO);			
			return tenantCompanyVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<TenantCompanyVO> pageVO(IPage<TenantCompanyEntity> pages) {
		IPage<TenantCompanyVO> page = pages.convert(item->{
            TenantCompanyVO tenantCompanyVO = new TenantCompanyVO();
		    BeanUtil.copyProperties(item, tenantCompanyVO);			
			return tenantCompanyVO;
		});
		return page;
	}
}
